package com.travelSpring.controller;

import com.travelSpring.annotation.RequireAdmin;
import com.travelSpring.common.Result;
import com.travelSpring.pojo.entity.ScenicCategory;
import com.travelSpring.service.ScenicCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 功能：
 * 作者：卷心菜
 * 日期：2025/4/14 20:57
 */
@RestController
@RequestMapping("/scenicCategory")
@RequireAdmin
public class VantorController {

    @Autowired
    ScenicCategoryService scenicCategoryService;
    //景点分类新增
    @PostMapping("/add")
    public Result save(@RequestBody ScenicCategory scenicCategory){
        scenicCategoryService.save(scenicCategory);
        return Result.success();
    }
    //景点分类修改
    @PostMapping("/update")
    public Result update(@RequestBody ScenicCategory scenicCategory){
        scenicCategoryService.update(scenicCategory);
        return Result.success();
    }

    //批量删除
    @DeleteMapping("/batchDelete")
    public Result deleteBatch(@RequestBody List<ScenicCategory> ids){
        scenicCategoryService.deleteBatch(ids);
        return Result.success();
    }
    //查询景点
    @GetMapping("/select")
    public Result query(ScenicCategory scenicCategory){
        List<ScenicCategory> query = scenicCategoryService.query(scenicCategory);
        return Result.success(query);
    }

    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Integer id){
        scenicCategoryService.delete(id);
        return Result.success();
    }
}
